// Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use std::path::Path;

use ohmw_codegen::msg_def::MsgDefMap;

#[tokio::test]
async fn gen_code() {
    let msgs_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../idl/msg");
    let msg_def_map = MsgDefMap::from_msgs_dir(msgs_dir).await
        .expect("failed to scan message definitions");

    let out_dir = Path::new(env!("CARGO_TARGET_TMPDIR")).join("msg");
    msg_def_map.gen_rust_crate(out_dir.join("rust"))
        .await
        .expect("failed to generate Rust code");
    msg_def_map.gen_cxx_project(out_dir.join("cxx"))
        .await
        .expect("failed to generate C++ code");
    msg_def_map.gen_arkts_protos(out_dir.join("arkts"))
        .await
        .expect("failed to generate ArkTS code");
    msg_def_map.gen_napi_project(out_dir.join("napi"))
        .await
        .expect("failed to generate NAPI code");
}
